home *** CD-ROM | disk | FTP | other *** search
/ Champak 128 / Vol 128 (Damaged).iso / games / boiler_b.swf / scripts / DefineSprite_209 / frame_1 / DoAction.as
Encoding:
Text File  |  2011-03-26  |  2.3 KB  |  97 lines

  1. var pState;
  2. var pX;
  3. var pY;
  4. var pNum;
  5. var pObjList = new Array("screw","fuse","nozzle","nut","spring");
  6. this.testRect = function(tx, ty)
  7. {
  8.    if(tx >= pRect[0] && tx <= pRect[2])
  9.    {
  10.       if(tY >= pRect[1] && ty <= pRect[3])
  11.       {
  12.          this._parent.camera_mc.setTarget(pY);
  13.          return pY;
  14.       }
  15.    }
  16. };
  17. this.setPos = function(ty)
  18. {
  19.    this._x = pX + 38;
  20.    this._y = pY - ty;
  21. };
  22. this.activate = function()
  23. {
  24.    var _loc1_ = this;
  25.    var _loc3_ = pObjList.length;
  26.    if(_loc3_ == 0)
  27.    {
  28.       _loc1_._parent.gameOver("win");
  29.    }
  30.    else
  31.    {
  32.       var _loc2_ = Math.floor(Math.random() * _loc3_);
  33.       _loc1_.pObj = pObjList[_loc2_];
  34.       _loc1_.pObjList.splice(_loc2_,1);
  35.       switch(pObj)
  36.       {
  37.          case "screw":
  38.             _loc1_.setUp(4,4);
  39.             break;
  40.          case "fuse":
  41.             _loc1_.setUp(4,64);
  42.             break;
  43.          case "nozzle":
  44.             _loc1_.setUp(34,61);
  45.             break;
  46.          case "nut":
  47.             _loc1_.setUp(35,96);
  48.             break;
  49.          case "spring":
  50.             _loc1_.setUp(24,115);
  51.       }
  52.       _loc1_._parent.top_mc.find_mc.gotoAndStop(pObj);
  53.       _loc1_._parent.top_mc.findtxt_mc.gotoAndStop("find");
  54.       _loc1_.pState = "active";
  55.       _loc1_.gotoAndStop(_loc1_.pObj);
  56.    }
  57. };
  58. this.collect = function()
  59. {
  60.    var _loc1_ = this;
  61.    _loc1_.pState = "collected";
  62.    _loc1_._parent.snd_mc.playsound("pFind");
  63.    _loc1_._parent.top_mc.addScore(10000);
  64.    _loc1_.pX = -1000;
  65.    switch(pObj)
  66.    {
  67.       case "screw":
  68.          _loc1_._parent.target0_mc.activate();
  69.          _loc1_._parent.bod_mc.setTarget(0);
  70.          break;
  71.       case "fuse":
  72.          _loc1_._parent.target1_mc.activate();
  73.          _loc1_._parent.bod_mc.setTarget(1);
  74.          break;
  75.       case "nozzle":
  76.          _loc1_._parent.target2_mc.activate();
  77.          _loc1_._parent.bod_mc.setTarget(2);
  78.          break;
  79.       case "nut":
  80.          _loc1_._parent.target3_mc.activate();
  81.          _loc1_._parent.bod_mc.setTarget(3);
  82.          break;
  83.       case "spring":
  84.          _loc1_._parent.target4_mc.activate();
  85.          _loc1_._parent.bod_mc.setTarget(4);
  86.    }
  87.    _loc1_._parent.top_mc.findtxt_mc.gotoAndStop("fix");
  88.    _loc1_.gotoAndStop(2);
  89. };
  90. this.setUp = function(x, y)
  91. {
  92.    this.pX = x * 16;
  93.    this.pY = y * 16;
  94. };
  95. this.activate();
  96. stop();
  97.